angular.module('app')

.factory('StockCategoryService', ['$http', function($http) {
	return {
		findCategoriesByStockId: function(stockId) { 
			console.log("GET findCategoriesByStockId.es?stockId="+stockId);
			return $http({
				method: 'GET',
				url: 'findCategoriesByStockId.es',
				params: {stockId: stockId}
			})
		},
		findCategoriesByStockCode: function(code) { 
			console.log("GET findCategoriesByStockCode.es?code="+code);
			return $http({
				method: 'GET',
				url: 'findCategoriesByStockCode.es',
				params: {code: code}
			})
		},
		
		// category list page
		findAllStockCategoies: function() {
			console.log("GET findAllStockCategoies.es");
			return $http({
				method: 'GET',
				url: 'findAllStockCategoies.es',
			})
		},
		
		saveStockCategory: function(categoryName) {
			console.log("GET saveStockCategory.es?categoryName="+categoryName);
			return $http({
				method: 'GET',
				url: 'saveStockCategory.es',
				params: {categoryName: categoryName}
			})
		},
		
		saveStockCategoryWithCode: function(code, categoryName) {
			console.log("GET saveStockCategoryWithCode.es?code="+code+"&categoryName="+categoryName);
			return $http({
				method: 'GET',
				url: 'saveStockCategoryWithCode.es',
				params: {code: code, categoryName: categoryName}
			})
		},
		
		deleteStockCategory: function(stockCategoryId) {
			console.log("GET deleteStockCategory.es?stockCategoryId="+stockCategoryId);
			return $http({
				method: 'GET',
				url: 'deleteStockCategory.es',
				params: {stockCategoryId: stockCategoryId}
			})
		},
		
		deleteStockCatRelate: function(stockCategoryId, stockId) {
			console.log("GET deleteStockCatRelate.es?stockCategoryId="+stockCategoryId+"&stockId="+stockId);
			return $http({
				method: 'GET',
				url: 'deleteStockCatRelate.es',
				params: {stockCategoryId: stockCategoryId, stockId: stockId}
			})
		},
		
	};
}])